﻿namespace Pibby.Core.Playlist
{
	public static class CanonicalPlaylistBuilder
	{
		public static PlaylistItemCollection Build (IPlaylist playlist, string baseFolder)
		{
			var canonical = new PlaylistItemCollection();

			foreach (var item in playlist.Items)
			{
				if (System.IO.Path.IsPathRooted(item.Path))
				{
					canonical.Add(item);
				}
				else
				{
					canonical.Add (new PlaylistItem (System.IO.Path.Combine (baseFolder, item.Path),
													item.Id));
				}
			}

			return canonical;
		}
	}
}
